package clients.test;

import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;

public class DynamicInvocationTest2 {

	public static void main(String[] argv) {
		try {
			String NS_XSD = "http://www.w3.org/2001/XMLSchema";
			ServiceFactory factory = ServiceFactory.newInstance();
			Service service = factory.createService(new QName(
					"http://webservices.samples.jboss.org/", "HelloWorldService"));

			Call call = service.createCall(new QName(
					"http://webservices.samples.jboss.org/", "HelloWorldPort"));

			call.setTargetEndpointAddress("http://localhost:8080/wservice/HelloWorld?wsdl");
			call.setOperationName(new QName(
					"http://webservices.samples.jboss.org/", "sayHello"));

			QName QNAME_TYPE_STRING = new QName(NS_XSD, "string");
			call.setReturnType(QNAME_TYPE_STRING);

			call.addParameter("arg0", QNAME_TYPE_STRING, ParameterMode.IN);
			String[] params = { "Murphy Brown" };

			String result = (String) call.invoke(params);
			System.out.println(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
